package com.example.flushdemo.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName CommonUtil
 * @Description
 * @Author Administrator
 * @Date 2022/9/28 0028 15:54
 * @Version 1.0
 */
public class FlushUtil {

    /**
     * 提示
     * @param total
     * @param used
     * @param days
     * @param fluctuationNum
     */
    public static void tip(int total, int used,int days,int fluctuationNum) {
        System.out.println("共计天数:"+days);
        System.out.println("每日数据量平均值:"+total/days);
        System.out.println("每日数据量范围:"+(total/days - fluctuationNum)+"-"+(total/days + fluctuationNum));
        System.out.println("需刷数据量:"+total+"条");
        System.out.println("共刷数据量:"+used+"条");
        String tip = "条------";
        tip = total-used < 0? "------多刷了"+(used-total)+tip: "------少刷了"+(total-used)+tip;
        System.out.println(tip);
    }

    /**
     * 获取工作日及周末平均数据量
     * @param startTime
     * @param endTime
     * @param total
     * @return
     */
    public static Map<String,Integer> getWeekendStrategy(String startTime, String endTime ,int total){
        //获取总天数
        int days = DateUtil.getDays(startTime, endTime);
        //获取周末天数
        int weekendNum = DateUtil.getTwoDaysDayDes(startTime, endTime);
        //非周末天数
        int dayNum = days - weekendNum;
        //设置默认周末数据量是工作日的三分之一
        //工作日平均数据量
        int weekdayAvg = total / (dayNum + weekendNum / 3);
        //周末平均数据量
        int weekendAvg = weekdayAvg / 3;
        Map<String,Integer> map = new HashMap<>();
        map.put("weekdayAvg",weekdayAvg);
        map.put("weekendAvg",weekendAvg);
        return map;
    }
}
